#ifndef _test_Communicator_h
#define _test_Communicator_h

#include <nemesis.comm.Communicator.h>

namespace test {

using namespace nemesis;

class Communicator : public comm::Communicator {
public:
   Communicator (WorkMode::_v workmode = WorkMode::Single) : comm::Communicator (workmode),
      a_maxMessage (-1), 
      a_messageCounter (0), 
      a_successCounter (0),
      a_initTime (0),
      a_avgDelay ("AvgDelay"),
      a_delay (0)
   {;}
   
   void setDelay (const Milisecond delay) throw () { a_delay = delay; }
   void setMaxMessage (const int maxMessage) throw () { a_maxMessage = maxMessage; }
   
   int getMaxMessage () const throw () { return a_maxMessage; }
   int getMessage () const throw () { return a_messageCounter; }

   bool canContinue (const comm::ClientSocket&) throw (RuntimeException);
   void delay () throw (RuntimeException);   
   
private:
   Milisecond a_delay;
   Milisecond a_initTime;
   int a_maxMessage;
   int a_messageCounter;
   int a_successCounter;
   Average <Microsecond> a_avgDelay;
   
   void eventOverQuota (const comm::ClientSocket&) throw ();      
   void terminate () throw ();
};

}

#endif
